#!/bin/bash

#[ "$1" == "" ] && echo "Usage: `basename $0` backup_file_full_path"

# One of the beautiful things of Linux is that This'll work even on a running system; 
# no need to screw around with boot-cd's or anything.
tar xpfj $1 -C /
echo "Restore complete!"

cd /
mkdir proc
mkdir lost+found
mkdir mnt
mkdir sys
mkdir pbfd
chmod 777 pbfd

cat /etc/passwd | awk -F":" '{print $6,$1}' | grep "^/home/" | \
while read home_dir user_name
do
  user_group="`groups $user_name | awk '{print $3}'`"
  echo "mkdir $home_dir"
  echo "chown $user_name:$user_group $home_dir"
done

